import {invoke} from "@tauri-apps/api/core";
import logo from "../assets/react.svg"

function FloatingBall() {
    // 处理双击事件的函数
    const handleDoubleClick = async () => {
        try {
            // 调用Rust中的命令来显示主窗口并隐藏悬浮球窗口
            await invoke('show_main_window_and_hide_floating_ball');
        } catch (error) {
            console.error("显示主窗口失败", error);
        }
    };

    return (
        <div
            data-tauri-drag-region
            className={`h-16 w-16 rounded-full flex justify-center items-center cursor-pointer`}
            onDoubleClick={handleDoubleClick}
        >
            <img data-tauri-drag-region src={logo} alt="logo" className={`h-16 w-16 rounded-full`}/>
        </div>
    );
}

export default FloatingBall;